#include "time0.h"
#include "f1c100s_timer.h"
#include "f1c100s_intc.h"
#include "stdio.h"
#include "FreeRTOS.h"
#include "task.h"
extern void vTickISR(void);
void timer0_init(void)
{
    // Configure timer to generate update event every 1ms
    tim_init(TIM0, TIM_MODE_CONT, TIM_SRC_HOSC, TIM_PSC_1);
    tim_set_period(TIM0, 24000000UL / 1000UL);
    tim_int_enable(TIM0);
    // IRQ configuration
    intc_set_irq_handler(IRQ_TIMER0, vTickISR);
    intc_enable_irq(IRQ_TIMER0);
    tim_start(TIM0);
    printf("\r\ntime0 start.\r\n");
    arm32_interrupt_enable();
}

void vApplicationStackOverflowHook(TaskHandle_t xTask, char *pcTaskName)
{
    printf("\r\nstack overflow:%s\r\n", pcTaskName);
}